import 'package:flutter_common_fragement/common/base/index.dart';
import 'package:flutter_common_fragement/common/utils/timer.dart';
import 'package:flutter_common_fragement/pages/root.dart';

class SplashViewModel extends BaseViewModel {
  bool _canPush = true;

  final _timerCountDown = TimerCountDown();

  void goRoot() {
    if (_canPush) {
      _canPush = false;
    }
  }

  @override
  void viewModelInitForContext(BuildContext context) {
    super.viewModelInitForContext(context);
    _timerCountDown.setTimerCount(1);
    _timerCountDown.startTimer(() {
      pushAndRemoveUntil(RootPage());
    });
  }

  @override
  void viewModelDispose() {
    super.dispose();
    _timerCountDown.destroyTimer();
  }
}
